// JavaScript Document
$(function () {
    bindMenus();
    bindFullScreen();

});

function bindMenus() {
    $(".secondMenu").slideUp(300);
    $(".menuBox").bind("mouseover", function () {
        $(this).find("a").addClass("ahover");
        $(this).find("span").addClass("shover");
        $(this).find(".secondMenu").slideDown(300);
    })

    $(".menuBox").bind("mouseleave", function () {
        $(this).find("a").removeClass("ahover");
        $(this).find("span").removeClass("shover");
        $(this).find(".secondMenu").slideUp(300);
    })

    $(".menuBox").bind("click", function () {
        if ($(this)[0].id != "fullScreen") {
            $(".menuBox").find("a").removeClass("aselected");
            $(".menuBox").find("span").removeClass("sselected");

            $(this).find("a").addClass("aselected");
            $(this).find("span").addClass("sselected");

            $("#workFrame").attr("src", $(this).attr("url"));
        }
    })
    $("#analysis a").bind("click", function () {
        $(".menuBox").find("a").removeClass("aselected");
        $(".menuBox").find("span").removeClass("sselected");

        $("#analysis a").eq("0").addClass("aselected");
        $("#analysis span").addClass("sselected");

        if ($(this).attr("url") != null)
            $("#workFrame").attr("src", $(this).attr("url"));
    })
}

function bindFullScreen() {
    $("#fullScreen").bind("click", function (e) {
        $(window).unbind('resize');
        FullScreen();
        setTimeout(function () {
            $(window).bind('resize', function () {
                FullScreen(true)
            });
        }, 500)
    })
    $("#foot").hide();
}

function FullScreen(desc) {
    var isFullscreen = document.fullScreen || document.mozFullScreen || document.webkitIsFullScreen;
    var el = document.getElementsByTagName("html")[0];
    if (isFullscreen || desc) {//推出全屏,
        document.exitFullscreen ? document.exitFullscreen() :
            document.mozCancelFullScreen ? document.mozCancelFullScreen() :
                document.webkitExitFullscreen ? document.webkitExitFullscreen() : '';
        $("#fullScreen a").html(" 全屏");
        $("#foot").hide();
    } else {	//多重短路表达式
        (el.requestFullscreen && el.requestFullscreen()) ||
        (el.mozRequestFullScreen && el.mozRequestFullScreen()) ||
        (el.webkitRequestFullscreen && el.webkitRequestFullscreen()) || (el.msRequestFullscreen && el.msRequestFullscreen());
        $("#fullScreen a").html(" 退出全屏");
        $("#foot").show();
    }
}